package com.neoCalf.neoGroup.controller;

import com.neoCalf.neoCommon.entity.ChatMessage;
import com.neoCalf.neoCommon.model.R;
import com.neoCalf.neoCommon.model.dto.SendMessageDto;
import com.neoCalf.neoGroup.service.SessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * @author 小牛
 * @version 1.0
 * @description TODO
 * @date 2025/4/18 19:38
 */
@RestController
@RequestMapping("/session")
@Validated
public class SessionController {
    @Autowired
    private SessionService sessionService;

    @PostMapping("/sendTextToGroup")
    public R<ChatMessage> sendText(@RequestBody @NotNull SendMessageDto<Object> sendMessageDto) {
        ChatMessage chatMessage = sessionService.sendText(sendMessageDto);
        return R.ok(chatMessage);
    }

    @PostMapping("/sendMediaToGroup")
    public R<ChatMessage> sendMedia(@RequestBody @NotNull SendMessageDto<MultipartFile> sendMessageDto) {
        ChatMessage chatMessage = sessionService.sendMedia(sendMessageDto);
        return R.ok(chatMessage);
    }
}
